package com.cee.controller;

import com.cee.common.result.Result;
import com.cee.dto.ShortAnswerDTO;
import com.cee.model.ShortAnswer;
import com.cee.service.ShortAnswerService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/shortAnswer")
public class ShortAnswerController {

    @Autowired
    private ShortAnswerService shortAnswerService;


    @PostMapping("/list")
    public Result getShortAnswerList(@RequestBody ShortAnswerDTO shortAnswerDTO){
        PageInfo pageInfo = shortAnswerDTO.getPageInfo();
        Page<ShortAnswerDTO> Page = PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());

        shortAnswerService.getShortAnswerList(shortAnswerDTO);
        return Result.ok(new PageInfo<>(Page));
    }


    @GetMapping("/delete")
    public Result deleteShortAnswer(Integer id){
        shortAnswerService.deleteShortAnswer(id);
        return Result.ok();
    }

}
